package com.aso.common.utils;

import android.content.Context;
import android.widget.Toast;

/**
 * Toast Utils class
 * Created by itsdf07 on 2017/7/9 09:59.
 * E-Mail: 923255742@qq.com
 * GitHub: https://github.com/itsdf07
 */

public class ToastUtils {
    public static final int TIME_SHORT = Toast.LENGTH_SHORT;
    public static final int TIME_LONG = Toast.LENGTH_LONG;

    private static Toast mToast;

    /**
     * @param text Toast提示内容
     */
    public static void showToast(String text) {
        showToast(Utils.getApplication(), text);
    }

    /**
     * @param context
     * @param text    Toast提示内容
     */
    public static void showToast(Context context, String text) {
        if (mToast == null) {
            mToast = Toast.makeText(context, text, TIME_SHORT);
        } else {
            mToast.setText(text);
        }
        mToast.show();
    }
}
